﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Data;

namespace ControlLibrary.Extensions;

public class MinMaxDeterminationConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        if (values.Length < 3 || values[2] is true ||
            values[0] is not DateTime currentDate ||
            values[1] is not IList<DateTime> { Count: > 0 } selectedDates)
            return false;
        var date = currentDate.Date;
        return date == selectedDates.Max().Date || date == selectedDates.Min().Date;
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}